/**
 * There are <a href="https://github.com/thinkgem/jeesite">JeeSite</a> code generation
 */
package com.chlitina.store.modules.sys.entity;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.hibernate.validator.constraints.Length;

import com.chlitina.store.common.persistence.BaseEntity;
import com.chlitina.store.modules.base.entity.Customer;
import com.google.common.collect.Lists;

/**
 * 店面Entity
 * @author liujiang
 * @version 2013-06-14
 */
@Entity
@Table(name = "store")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Store extends BaseEntity {
	public static final int NEED_LOGIN_PW= 0;
	public static final int NONEED_LOGIN_PW = 1;
	public static final int NEW_STORE_TIP_NO = 0;
	public static final int NEW_STORE_TIP_YES = 1;
	
	private static final long serialVersionUID = 1L;
	private Long id; 				// 店面编号
	private Area area; 				// 区域编号
	private String name;			// 店面名称
	private String address;			// 店面地址
	private String linkman;			//联系人
	private String bossMobile;			//老板电话
	private String phone;			//联系电话
	private Date create_date;		//添加门店到系统的日期
	private Date start_date;		//开店时间
	private int rank;				//店面等级：0：新开店1：普通店（待定）2：高级店（待定）
	private int sms_remain_amount;  //门店剩余短消息数量
	private float account_balance;  //账户余额
	private String loginName;			//店面登陆账号
	private String loginPassword;			//店面登陆密码
	private String bossPassword;			//老板登陆密码
	private int expertManualAmount;			//店面每个月人工请求次数
	private StoreType storeType;			//店面类型（克缇店、莉缇店、经销商）
	private int need_login_pw;				//0：需要密码 1：不需要密码
	private Date end_date;			//店面使用期限
	private int new_store_tip;				//新店开业是否已通知：0：未通知1：已通知
	private int allow_amount;				//允许登陆数量
	private int current_amount;				//实时登陆数量
	
	private List<Customer> customerList = Lists.newArrayList();
	private List<StoreLogin> loginList = Lists.newArrayList();
	
	public Store() {
		this.account_balance = 0;
	}

	public Store(Long id){
		this();
		this.id = id;
	}
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	
	@Length(min=1, max=16)
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	@ManyToOne(cascade={CascadeType.REFRESH}, fetch = FetchType.LAZY) 
	@JoinColumn(name="region_id")
	@NotFound(action = NotFoundAction.IGNORE)
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	@NotNull
	public Area getArea() {
		return area;
	}

	public void setArea(Area area) {
		this.area = area;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getLinkman() {
		return linkman;
	}

	public void setLinkman(String linkman) {
		this.linkman = linkman;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	
	public Date getCreate_date() {
		return create_date;
	}

	public void setCreate_date(Date create_date) {
		this.create_date = create_date;
	}

	public Date getStart_date() {
		return start_date;
	}

	public void setStart_date(Date start_date) {
		this.start_date = start_date;
	}

	public int getRank() {
		return rank;
	}

	public void setRank(int rank) {
		this.rank = rank;
	}

	public int getSms_remain_amount() {
		return sms_remain_amount;
	}

	public void setSms_remain_amount(int sms_remain_amount) {
		this.sms_remain_amount = sms_remain_amount;
	}

	public float getAccount_balance() {
		return account_balance;
	}

	public void setAccount_balance(float account_balance) {
		this.account_balance = account_balance;
	}
	
	public String getBossMobile() {
		return bossMobile;
	}

	@Column(name="boss_mobile")
	public void setBossMobile(String bossMobile) {
		this.bossMobile = bossMobile;
	}

	public String getLoginName() {
		return loginName;
	}

	public void setLoginName(String loginName) {
		this.loginName = loginName;
	}

	@Column(name="login_password")
	public String getLoginPassword() {
		return loginPassword;
	}

	public void setLoginPassword(String loginPassword) {
		this.loginPassword = loginPassword;
	}

	@Column(name="boss_password")
	public String getBossPassword() {
		return bossPassword;
	}

	public void setBossPassword(String bossPassword) {
		this.bossPassword = bossPassword;
	}

	@Column(name="expert_manual_amount")
	public int getExpertManualAmount() {
		return expertManualAmount;
	}

	public void setExpertManualAmount(int expertManualAmount) {
		this.expertManualAmount = expertManualAmount;
	}

	@OneToMany(cascade={CascadeType.REFRESH, CascadeType.MERGE},fetch=FetchType.LAZY,mappedBy="store")
	@NotFound(action = NotFoundAction.IGNORE)
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	public List<Customer> getCustomerList() {
		return customerList;
	}

	public void setCustomerList(List<Customer> customerList) {
		this.customerList = customerList;
	}
	
	@ManyToOne(cascade={CascadeType.REFRESH}, fetch = FetchType.LAZY) 
	@JoinColumn(name="STORE_TYPE")
	@NotFound(action = NotFoundAction.IGNORE)
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	@NotNull
	public StoreType getStoreType() {
		return storeType;
	}

	public void setStoreType(StoreType storeType) {
		this.storeType = storeType;
	}
	
	public int getNeed_login_pw() {
		return need_login_pw;
	}

	public void setNeed_login_pw(int need_login_pw) {
		this.need_login_pw = need_login_pw;
	}
	
	@OneToMany(cascade={CascadeType.REFRESH, CascadeType.MERGE},fetch=FetchType.LAZY,mappedBy="store")
	@NotFound(action = NotFoundAction.IGNORE)
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	public List<StoreLogin> getIpadList() {
		return loginList;
	}

	public void setIpadList(List<StoreLogin> loginList) {
		this.loginList = loginList;
	}

	public Date getEnd_date() {
		return end_date;
	}

	public void setEnd_date(Date end_date) {
		this.end_date = end_date;
	}
	
	public int getNew_store_tip() {
		return new_store_tip;
	}

	public void setNew_store_tip(int new_store_tip) {
		this.new_store_tip = new_store_tip;
	}
	
	public int getAllow_amount() {
		return allow_amount;
	}

	public void setAllow_amount(int allow_amount) {
		this.allow_amount = allow_amount;
	}

	public int getCurrent_amount() {
		return current_amount;
	}

	public void setCurrent_amount(int current_amount) {
		this.current_amount = current_amount;
	}
}


